#include <iostream>
#include <string>
#include <unordered_map>
#include <algorithm>
using namespace std;

int n;
string word;
string dict[1004];
int k;
int cur;
string brothers[1004];

bool isbro(string s1, string s2){
    if(s1 == s2) return 0;
    if(s1.length() != s2.length()) return 0;
    unordered_map<char,int> m1;
    unordered_map<char,int> m2;
    for(int i=0;i<s1.length();i++) m1[s1[i]]++;
    for(int i=0;i<s2.length();i++) m2[s2[i]]++;
    if(m1.size() != m2.size()) return 0;
    for(auto iter1 = m1.begin();iter1 != m1.end();iter1++){
        auto iter2 = m2.find(iter1->first);
        if(iter2 == m2.end()) return 0;
        if(iter1->second != iter2->second) return 0;
    }
    return 1;
}

int main() {
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> dict[i];
    }
    cin >> word;
    cin >> k;


    for(int i=0;i<n;i++){
        if(isbro(dict[i], word)) brothers[cur++] = dict[i];
    }

    sort(brothers, brothers+cur, [](string s1, string s2){
        return s1 < s2;
    });

    cout << cur+1 << endl;
    cout << brothers[k-1] << endl;

    return 0;
}